<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layuiAdmin 网站用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div style="padding-bottom: 10px;">
        <button class="layui-btn layuiadmin-btn-useradmin" data-type="add">缴费</button>
    </div>

    <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>

</div>

<script src="../../../layuiadmin/layui/layui.js"></script>
<script th:inline="none">
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'useradmin', 'table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;
        table.render({
            elem: "#LAY-user-manage",
            url: '/yezhu/payperson',
            cellMinWidth: 80,
            cols: [[
                {field: 'id', width: 80, title: 'ID', sort: true},
                {field: 'username', width: 150, title: '业主姓名'},
                {field: 'money', width: 150, title: '账户余额'},
                {field: 'water', width: 150, title: '水费余额'},
                {field: 'electric', width: 150, title: '电费余额'},
                {field: 'gas', width: 150, title: '燃气余额'},
                {field: 'tenement', width: 150, title: '物业费余额'}
            ]],
            id: "listData",
            page: true

        });
        //事件
        var active = {

            add: function () {
                layer.open({
                    type: 2
                    , title: '缴费'
                    , content: '/yezhu/personadd'
                    , maxmin: true
                    , area: ['500px', '450px']
                    , btn: ['确定', '取消']
                    , yes: function (index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index]
                            , submitID = 'LAY-user-front-submit'
                            , submit = layero.find('iframe').contents().find('#' + submitID);

                        //监听提交
                        iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                            var field = data.field; //获取提交的字段

                            //提交 Ajax 成功后，静态更新表格中的数据
                            //$.ajax({});
                            table.reload('LAY-user-front-submit'); //数据刷新
                            layer.close(index); //关闭弹层
                        });

                        submit.trigger('click');
                    }
                });
            }
        };

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>


</body>
</html>
